<?php
include('../../inc/global.inc');
include("../islogin.php");
$url="search.php";
$thepage=$_GET['page']?$_GET['page']:1;
$maxpage=20;
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
<script language="javascript" src="/member/js/catalog.js" type="text/javascript" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">产品搜索&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
  <table width="95%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="5"></td>
    </tr>
  </table><table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <form method="get" action="" name="form1">
      <tr>
        <td height="25" bgcolor="#EEEEF9" style="padding:5px;line-height:25px;"><strong>高级搜索:</strong>
          <input name="search_name" type="text" size="35">
          &nbsp;&nbsp;请输入产品名称<input type="submit" value="搜索"></td>
      </tr>
    </form>
  </table>
<?php 
if($_GET[search_name]){
$search_sql=" and (product.p_title like '%$_GET[search_name]%' or product.p_keyword like '%$_GET[search_name]%')";
}
?>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td width="11%" height="30" align="center" bgcolor="#8DA8CF">图片</td>
      <td width="49%" align="center" bgcolor="#8DA8CF">产品信息</td>
      <td width="15%" align="center" bgcolor="#8DA8CF">联系电话</td>
      <td width="12%" align="center" bgcolor="#8DA8CF">联系手机</td>
      <td width="13%" align="center" bgcolor="#8DA8CF">在线QQ</td>
    </tr>
<?php
$sql="select product.id,product.p_title,product.p_info,product.p_price,member.m_user,member.m_type,member.m_cname,member.m_tel,member.m_phone,member.m_qq from product inner join  member on (product.member_id=member.id) where  product.p_sh=1 ".$search_sql." order by product.id desc limit ".($thepage-1)*$maxpage.",$maxpage";

$rs=@mysql_query($sql);
$i=1;
while($row=@mysql_fetch_array($rs)){
if($row[m_type]==6){
   $m_url="http://$row[m_user].sandib2b.cn/";
}else{
   $m_url="/cn/template/$row[m_user]/";
}
$color=($i%2)?"#FFFFFF":"#eeeeee";
?>
    <tr bgcolor=<?=$color?>>
      <td height="25" align="center"><a href="/supply/<?=$row['id']?>.html" target="_blank">
<?php if(trim($row[picture])){?>
<img src="http://www.sandib2b.cn/upfile/<?=$row[picture]?>" alt="<?=$row[p_title]?>" border="0" <?=imgstr("http://www.sandib2b.cn/upfile/$row[picture]","80","80")?>/>
<?php }else{?>
<img src="/images/prono88.gif" width=80 height=80 border="0" />
<?php }?></a></td>
	  <td align="left" valign="top" style="padding-left:5px;"><a href="/supply/<?=$row['id']?>.html" target="_blank"><?=mb_substr($row[p_title],0,16,'utf-8')?></a><br>
<?=mb_substr(strip_tags($row[p_info]),0,50,'utf-8')?><br>
<font color="#FF0000">价格：<?=$row[p_price]?></font><br>
<A href="<?=$m_url?>" target=_blank><?=$row['m_cname']?></A>
</td>
	  <td align="center"><?=$row['m_tel']?></td>
	  <td align="center"><?=$row['m_phone']?></td>
      <td align="center"><?=$row['m_qq']?></td>
    </tr>
<?php
$i++;}
//分页参数
$rs2=@mysql_query("select count(product.id) from product inner join  member on (product.member_id=member.id) where  product.p_sh=1 ".$search_sql);
$totalrecord=@mysql_result($rs2,0);
$totalpage=ceil($totalrecord/$maxpage);
@mysql_free_result($rs2);
?>
<tr><form method="get" action="<?=$url?>?search_name=<?=$_GET[search_name]?>">
   <td height="25" colspan="5" align="center" bgcolor="#FFFFFF">
<?php if($thepage>1){?>
   <a href="<?=$url?>?search_name=<?=$_GET[search_name]?>">第一页</a>&nbsp;<a href="<?=$url?>?page=<?=$thepage-1?>&search_name=<?=$_GET[search_name]?>">上一页</a>&nbsp;
<?php }?>  
<?php if($thepage!=$totalpage&&$totalpage>0){?>
   <a href="<?=$url?>?page=<?=$thepage+1?>&search_name=<?=$_GET[search_name]?>">下一页</a>&nbsp;<a href="<?=$url?>?page=<?=$totalpage?>&search_name=<?=$_GET[search_name]?>">最后一页</a>&nbsp;
<?php }?>   
   【共<font color="red"><?=$totalrecord?></font>条记录】【每页<font color="red"><?=$maxpage?></font>条记录】【共<font color="red"><?=$totalpage?></font>页】<input type="text" name="page" size="3" onKeyUp="IsDigit(this);">&nbsp;<input type="submit" value="GO"></td></form>
</tr>
  </table>
</center>
</BODY>
</HTML>


<script language="javascript">
function IsDigit(obj) 
{ 
if(obj.value.replace(/[\d+]/ig,"").length>0) { 
  alert('enter an number'); 
  document.getElementById(obj).value =""; 
} 
} 
</script>